function genpwd(options){			  
	this.options = jQuery.extend({  
		withdigits:false,
		withletters:false,
		withspecialchar:false,
		capital:false
	}, options);
}							
genpwd.prototype.gen = function(len){
	var pwd='', c;
	while(pwd.length < len){
		c = this.getchar()
		if(c !== false){ 
			pwd += c;
		}
	}
	return pwd;
}
genpwd.prototype.getchar = function(){
	var seed = parseInt(Math.random() * 3), char=false;
	switch(seed){
		case 0:			  
			char = this.getDigit();
			break;
		case 1:		  
			char = this.getLetters();
			break;
		case 2:
			char = this.getSpecialchar();
			break;
	}
	return char;
}	   
genpwd.prototype.getDigit = function(){	
	if(this.options.withdigits){
		return parseInt(Math.random() * 10);
	}
	return false;
}	   

genpwd.prototype.getLetters = function(){	
	if(this.options.withletters){
		var c = String.fromCharCode(parseInt(Math.random() * 25) + 97)
		if(this.options.capital){
			c = Math.random() > 0.5 ? c.toLowerCase() : c.toUpperCase()
		}
		return c;
	}
	return false;
}	
genpwd.prototype.getSpecialchar = function(){	  
	if(this.options.withspecialchar){			
		var sample = '`-=~!@#$%^&*()_+[]\{}|;\',./<>?:"';
		return sample.charAt(parseInt(Math.random() * sample.length));
	}
	return false;
}	   
